<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="time"></div>
    <script>
        //倒计时函数：根据输入的时间，给出当前时间距离输入时间的倒计时内容；效果：距离某个时间，还有 x天x时x分x秒
        var time = setInterval(function () {
            var nowTime = +new Date();
            var furtureTime = + new Date("2021-10-06 15:15:09");
            var days = parseInt((furtureTime - nowTime) / 1000 / 60 / 60 / 24);
            var days2 = days < 10 ? '0' + days : days;
            var hourse = parseInt((furtureTime - nowTime) / 1000 / 60 / 60 % 24);
            var hourse2 = hourse < 10 ? '0' + hourse : hourse;
            var minutes = parseInt((furtureTime - nowTime) / 1000 / 60 % 60);
            var minutes2 = minutes < 10 ? '0' + minutes : minutes;
            var seconds = parseInt((furtureTime - nowTime) / 1000 % 60);
            var seconds2 = seconds < 10 ? '0' + seconds : seconds;
            var n = days2 + "天" + hourse2 + "时" + minutes2 + "分" + seconds2 + "秒";
            document.getElementById("time").innerHTML = n;
        }, 1000);
    </script>
</body>

</html>